<?php

namespace App\Front;

use App\Http\Controllers\Controller;
use App\Models\Policy;
use Illuminate\Http\Request;

class PolicyController extends Controller
{
//政策
    public function index()
    {
        $policies = Policy::select(['id', 'title', 'created_at', 'readedTimes', 'preview'])->orderByDesc('id')->paginate(10);
        return $policies;
    }

    public function show(Request $request, Policy $policy)
    {
        $policy->readedTimes++;
        $policy->save();
        return $policy;
    }
}
